//
//  TraderMiddleManFooterView.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/4/17.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "TraderMiddleManFooterView.h"
#import "AddMiddleManViewController.h"

@interface TraderMiddleManFooterView()


@property (weak, nonatomic) IBOutlet UIImageView *tickImg;

-(IBAction)clickBtn:(UIButton *)btn;
//移动
@property (weak, nonatomic) IBOutlet UIButton *removeBtn;
//启用
@property (weak, nonatomic) IBOutlet UIButton *startUseBtn;
//禁用
@property (weak, nonatomic) IBOutlet UIButton *forbiddenBtn;
@property(nonatomic,assign) BOOL isShowRemoveBtn;


@end
@implementation TraderMiddleManFooterView

+(instancetype)TraderMiddleManFooterViewWithXibWithIsShowRemoveBtn:(BOOL)isShowRemoveBtn;
{
    TraderMiddleManFooterView *view = [[[NSBundle mainBundle]loadNibNamed:@"TraderMiddleManFooterView" owner:nil options:nil]lastObject];
    view.isShowRemoveBtn = isShowRemoveBtn;
    return view;
}

-(void)layoutSubviews
{
   
    if (!self.isShowRemoveBtn)
    {
        CGRect startUseBtnFrame = self.startUseBtn.frame;
        CGRect forbiddenBtnFram = self.forbiddenBtn.frame;
        self.startUseBtn.frame = self.removeBtn.frame;
        self.forbiddenBtn.frame = startUseBtnFrame;
        self.removeBtn.hidden = YES;
        [self.removeBtn setEnabled:NO];
        self.removeBtn.frame = forbiddenBtnFram;
    }else
    {
//        CGRect startUseBtnFram = self.startUseBtn.frame;
//        CGRect forbiddenBtnFram = self.forbiddenBtn.frame;
//        self.startUseBtn.frame = forbiddenBtnFram;
//        self.forbiddenBtn.frame = self.removeBtn.frame;
//        self.removeBtn.frame = startUseBtnFram;
//        self.removeBtn.hidden = NO;
//        [self.removeBtn setEnabled:YES];
//         NSLog(@"99999     %d",self.isShowRemoveBtn);
    }
}
#pragma mark 点击按钮，tag＝0 全选，＝1 移动，＝2 禁用，＝3 启用
-(IBAction)clickBtn:(UIButton *)btn;
{
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(tradermiddleManFooterViewClickBtnWithTag:andImgTag:)])
    {
        if (btn.tag == 0)
        {
            if (self.tickImg.tag == 0)
            {
                self.tickImg.image = [UIImage imageNamed:@"fuxuan_birder_si"];
                self.tickImg.tag = 1;
            }else
            {
                self.tickImg.image = [UIImage imageNamed:@"fuxuan_birder"];
                self.tickImg.tag = 0;

            }
            
        }
        [self.delegate tradermiddleManFooterViewClickBtnWithTag:btn.tag andImgTag:self.tickImg.tag];
    }
}
    
@end
